#pragma once

#include "AcceptEventAction.h"

#include "OutputPin.h"
#include "Trigger.h"

namespace uml {

const bool AcceptEventAction::isUnmarshall_default_ = false;
AcceptEventAction::AcceptEventAction(const QString& umlType)
    : Action(umlType) {}

void AcceptEventAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Action::fromJson(json, errorList);
    isUnmarshall_ = json.value("isUnmarshall").toBool(isUnmarshall_default_);
    JsonSerializable::fromJsonArray(results_, "results", json, errorList);
    JsonSerializable::fromJsonArray(triggers_, "triggers", json, errorList);
}

void AcceptEventAction::toJson(QJsonObject& json) {
    Action::toJson(json);
    if (isUnmarshall_ != isUnmarshall_default_) {
        json.insert("isUnmarshall", isUnmarshall_);
    }
    JsonSerializable::toJsonArray(results_, "results", json);
    JsonSerializable::toJsonArray(triggers_, "triggers", json);
}

/// <summary>
/// isUnmarshall getter
/// Indicates whether there is a single OutputPin for a SignalEvent occurrence, or
/// multiple OutputPins for attribute values of the instance of the Signal
/// associated with a SignalEvent occurrence.
/// </summary>
bool AcceptEventAction::isUnmarshall() const {
    return isUnmarshall_;
}

/// <summary>
/// isUnmarshall setter
/// Indicates whether there is a single OutputPin for a SignalEvent occurrence, or
/// multiple OutputPins for attribute values of the instance of the Signal
/// associated with a SignalEvent occurrence.
/// </summary>
void AcceptEventAction::setIsUnmarshall(bool value) {
    isUnmarshall_ = value;
}

/// <summary>
/// results getter
/// OutputPins holding the values received from an Event occurrence.
/// </summary>
vector<shared_ptr<OutputPin>>& AcceptEventAction::results() {
    return results_;
}

/// <summary>
/// triggers getter
/// The Triggers specifying the Events of which the AcceptEventAction waits for
/// occurrences.
/// </summary>
vector<shared_ptr<Trigger>>& AcceptEventAction::triggers() {
    return triggers_;
}

} // namespace uml
